<template>
  <van-overlay :show="visible">
    <div class="confirmation_box">
      <slot name="text"></slot>
      <div>{{ text }}</div>
      <div class="buttons">
        <div @click="handleCancel">取消</div>
        <div @click.stop="handleOk">确认</div>
      </div>
    </div>
  </van-overlay>
</template>

<script lang="ts">
import { defineComponent } from 'vue'
export default defineComponent({
  props: {
    text: {
      type: String
    },
    visible: {
      type: Boolean
    }
  },
  setup(props, context) {
    const handleOk = () => {
      context.emit('ok', '')
    }
    const handleCancel = () => {
      context.emit('cancel', '')
    }
    return {
      handleOk,
      handleCancel
    }
  }
})
</script>

<style scoped>
.confirmation_box {
  margin: 80% 10%;
  padding: 20px;
  position: fixed;
  left: 0;
  right: 0;
  background-color: #fff;
}
  .buttons {
    display: flex;
    margin: 20px 20px 0;
    justify-content: space-between;
  }
</style>